import os

from google.appengine.ext import webapp
from google.appengine.api import users
from google.appengine.ext import db
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class TestDB(db.Model):
  vstr = db.StringProperty(multiline = True)

class MainHandler(webapp.RequestHandler):

  def get(self):
    #self.response.out.write('Hello world!')
    
    view_manage_path = os.path.join(os.path.dirname(__file__), 'view/manage.htm')
    
    view_main_path = os.path.join(os.path.dirname(__file__), 'view/main.htm')
    
    view_manage_values = {
      'user': users.get_current_user(),
      'hStr' : heS
      }
    
    manage_page = template.render(view_manage_path, view_manage_values)
    
    view_main_values = {
      'mainpage': manage_page
      }
    
    self.response.out.write(template.render(view_main_path, view_main_values))

class PostValue(webapp.RequestHandler):

  def post(self):
    testDB = TestDB()
    
    testDB.vstr = self.request.get('value')
    testDB.put()
    self.redirect('/manager/')

def main():
  application = webapp.WSGIApplication([('/manager', MainHandler),
                                    ('/manager/', MainHandler),
                                    ('/manager/post', PostValue)],
                                       debug=True)
  util.run_wsgi_app(application)


if __name__ == '__main__':
  main()
